﻿namespace System.ServiceModel.DomainServices.Client
{
    using System;

    internal class DomainClientAsyncResult : AsyncResultBase
    {
        private readonly System.ServiceModel.DomainServices.Client.AsyncOperationType _asyncOperationType;
        private readonly System.ServiceModel.DomainServices.Client.DomainClient _domainClient;
        private readonly System.ServiceModel.DomainServices.Client.EntityChangeSet _entityChangeSet;
        private readonly System.ServiceModel.DomainServices.Client.InvokeArgs _invokeArgs;

        protected DomainClientAsyncResult(System.ServiceModel.DomainServices.Client.DomainClient domainClient, AsyncCallback callback, object asyncState) : base(callback, asyncState)
        {
            if (domainClient == null)
            {
                throw new ArgumentNullException("domainClient");
            }
            this._asyncOperationType = System.ServiceModel.DomainServices.Client.AsyncOperationType.Query;
            this._domainClient = domainClient;
        }

        protected DomainClientAsyncResult(System.ServiceModel.DomainServices.Client.DomainClient domainClient, System.ServiceModel.DomainServices.Client.EntityChangeSet entityChangeSet, AsyncCallback callback, object asyncState) : base(callback, asyncState)
        {
            if (domainClient == null)
            {
                throw new ArgumentNullException("domainClient");
            }
            this._asyncOperationType = System.ServiceModel.DomainServices.Client.AsyncOperationType.Submit;
            this._domainClient = domainClient;
            this._entityChangeSet = entityChangeSet;
        }

        protected DomainClientAsyncResult(System.ServiceModel.DomainServices.Client.DomainClient domainClient, System.ServiceModel.DomainServices.Client.InvokeArgs invokeArgs, AsyncCallback callback, object asyncState) : base(callback, asyncState)
        {
            if (domainClient == null)
            {
                throw new ArgumentNullException("domainClient");
            }
            if (invokeArgs == null)
            {
                throw new ArgumentNullException("invokeArgs");
            }
            this._asyncOperationType = System.ServiceModel.DomainServices.Client.AsyncOperationType.Invoke;
            this._domainClient = domainClient;
            this._invokeArgs = invokeArgs;
        }

        public static DomainClientAsyncResult CreateInvokeResult(System.ServiceModel.DomainServices.Client.DomainClient domainClient, System.ServiceModel.DomainServices.Client.InvokeArgs invokeArgs, AsyncCallback callback, object asyncState)
        {
            return new DomainClientAsyncResult(domainClient, invokeArgs, callback, asyncState);
        }

        public static DomainClientAsyncResult CreateQueryResult(System.ServiceModel.DomainServices.Client.DomainClient domainClient, AsyncCallback callback, object asyncState)
        {
            return new DomainClientAsyncResult(domainClient, callback, asyncState);
        }

        public static DomainClientAsyncResult CreateSubmitResult(System.ServiceModel.DomainServices.Client.DomainClient domainClient, System.ServiceModel.DomainServices.Client.EntityChangeSet entityChangeSet, AsyncCallback callback, object asyncState)
        {
            return new DomainClientAsyncResult(domainClient, entityChangeSet, callback, asyncState);
        }

        public System.ServiceModel.DomainServices.Client.AsyncOperationType AsyncOperationType
        {
            get
            {
                return this._asyncOperationType;
            }
        }

        public System.ServiceModel.DomainServices.Client.DomainClient DomainClient
        {
            get
            {
                return this._domainClient;
            }
        }

        public System.ServiceModel.DomainServices.Client.EntityChangeSet EntityChangeSet
        {
            get
            {
                return this._entityChangeSet;
            }
        }

        public System.ServiceModel.DomainServices.Client.InvokeArgs InvokeArgs
        {
            get
            {
                return this._invokeArgs;
            }
        }
    }
}

